<?php
/*----------------------------------------------------------------------
#Youjoomla News Ticker  
# ----------------------------------------------------------------------
# Copyright (C) 2007 You Joomla. All Rights Reserved.
# Designed by: Youjoomla.com
# Commercial
# Website: http://www.youjoomla.com// Copyright (c) 2006 - 2008 Youjoomla LLC
# This code cannot be redistributed without permission from Youjoomla - http://www.youjoomla.com.
# More info at http://www.youjoomla.com 
# Developer: Dragan Todorovic
------------------------------------------------------------------------*/

// no direct access
defined('_JEXEC') or die('Restricted access');
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
$database					=& JFactory::getDBO();
$mosConfig_absolute_path	= JPATH_ROOT;
$mosConfig_live_site 		= JURI :: base(); 
  
  
require_once('modules/mod_yj_news_ticker/lib/slike.php');

global $mosConfig_absolute_path, $mosConfig_live_site, $mainframe, $database, $_MAMBOTS;


$database					=& JFactory::getDBO();
$mosConfig_absolute_path	= JPATH_ROOT;
$mosConfig_live_site 		= JURI :: base(); 


$phpversion=$params->get('phpversion',"1");
$mootools=$params->get('mootools',"0");
$compress=$params->get('compress',"0");

$width = $params->get ('width','400px');
$height = $params->get ('height','500px');
$mod_title = $params->get ('mod_title','Lates from Sports');
$speed =  $params->get ('speed','800');
$delay =  $params->get ('delay','6000');
$pic_h =  $params->get ('pic_h','32px');
$pic_w =  $params->get ('pic_w','32px');
$bg_nt =  $params->get ('bg_nt','#efefef'); 
$border_nt =  $params->get ('border_nt','solid 1px #ccc');
$bg_h1 =  $params->get ('bg_h1','#DFDFDF');
$get_items = $params->get('get_items',1);
$nitems = $params->get ('nitems',5);
$chars = $params->get ('chars',200);
$show_date =  $params->get ('show_date','1');
$show_by =  $params->get ('show_by','1');
$show_hits = $params->get ('show_hits','1');

$ordering = $params->get('ordering',1);// 1 = ordering | 2 = popular | 3 = random 

////////////////////////// /BRAKE YOUR BRAIN! I BROKE MINE :) //////////////////////////////////


if($ordering ==1){
$order = 'ordering';
}elseif($ordering == 2){
$order = 'hits';
}elseif ($ordering == 3){
$order = 'RAND()';
}

$inh = $height -64;	
if($compress ==1 ){
$mooext= 'php';
}else{
$mooext= 'js';
}
echo "<!-- http://www.Youjoomla.com News Ticker  for Joomla 1.5 starts here --> ";

$linktag_yjnst = '<link rel="stylesheet" type="text/css" href="'.$mosConfig_live_site.'/modules/mod_yj_news_ticker/css/style.css" />';



if ($mootools == 1){
  $linktag_yjnst.= '<script src="modules/mod_yj_news_ticker/lib/mootools.'.$mooext.'" type="text/javascript"></script>';

  }else{}






$slyle_yjnst="<style type=\"text/css\">";
$slyle_yjnst.="

#yj_nt1{
border:{$border_nt};
background:{$bg_nt};
height:{$height};
margin:0 auto;
overflow:hidden;
}
#yj_nt1 h1{
padding:6px; margin:0; border:0;
background:{$bg_h1};
color:#000000;
font-size:11px;
font-weight:bold;
border-bottom:1px solid #e5e5e5;
}
#yj_nv_nt1 {
height: {$inh}px;
display: block;
overflow: hidden;
position: relative;
}
#yj_nt_holder_nt1{
padding:6px;
font-size:11px;
color:#666;
position: relative;
left:0;
top:-21px;
}
#yj_ntver_nt1 li .yj_ntt_nt1{
line-height:{$pic_h};
}
";
$slyle_yjnst.="</style>";
$linktag_yjnst.=$slyle_yjnst;

$mainframe->addCustomHeadTag($linktag_yjnst);

?>

		
        
<?php
$database					=& JFactory::getDBO();
$mosConfig_absolute_path	= JPATH_ROOT;
$mosConfig_live_site 		= JURI :: base(); 
        
  $now 		    = date('Y-m-d H:i:s');
  $database 	=& JFactory::getDBO();
  $nullDate 	= $database->getNullDate();





		$db			=& JFactory::getDBO();
		$user		=& JFactory::getUser();
		$userId		= (int) $user->get('id');
		$aid		= $user->get('aid', 0);

		$contentConfig = &JComponentHelper::getParams( 'com_content' );
		$access		= !$contentConfig->get('shownoauth');

		$nullDate	= $db->getNullDate();

		$date =& JFactory::getDate();
		$now = $date->toMySQL();

		$where		= 'a.state = 1'
			. ' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )'
			. ' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'
			;



$sql = 'SELECT a.*, ' .
' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'. 
' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
			' FROM #__content AS a' .
			' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
			' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
			' WHERE '. $where .' AND cc.id = '.$get_items.'' .
			($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
			' AND s.published = 1' .
			' AND cc.published = 1' .
			' ORDER BY '.$order .' LIMIT 0,'.$nitems.'';






$database->setQuery( $sql );
$load_items = $database->loadObjectList();

?>
<script type="text/javascript">
window.addEvent('domready', function() {
   var pauza = new yjNT('yj_ntver_nt1', {
      speed : <?php echo $speed ?>, delay : <?php echo $delay ?>, direction : 'vertical'});
   $('yj_nt1').addEvent('mouseenter', function() {
        $('play_scroll_nt1').style.display='block';
		$('stop_scroll_nt1').style.display='none';							   
			pauza.pause();
	});
	
	   $('yj_nt1').addEvent('mouseleave', function() {
		$('stop_scroll_nt1').style.display='block';
		$('play_scroll_nt1').style.display='none';
			pauza.resume();
	});

	
});




</script>


<div id="yj_nt1" style="width:<?php echo $width ?>;">
  <h1><?php echo $mod_title ?></h1>
  <div id="yj_nt_holder_nt1">
 
  
    <div id="control">
<div id="stop_scroll_nt1"><a id="stop_scroll"><img  src="<?php echo $mosConfig_live_site;?>/modules/mod_yj_news_ticker/images/play.png" width="10px" height="10px" border="0" align="middle" alt="Stop" /></a> </div>
    <div id="play_scroll_nt1"><a id="play_scroll"><img src="<?php echo $mosConfig_live_site;?>/modules/mod_yj_news_ticker/images/pause.png" width="10px" height="10px" border="0" align="middle" alt="Play"/></a> </div>
</div>
  
  
  
    </div>
<div id="yj_nv_nt1" style="width:<?php echo $width ?>;">
	  <ul id="yj_ntver_nt1" style="width:<?php echo $width ?>;">
      
      <?php foreach ( $load_items as $row ) {
require('modules/mod_yj_news_ticker/lib/slike1.php');

$date = JHTML::_('date', $row->created, '', '');
$link = ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid);
$intro 	= substr(strip_tags($row->introtext),0,$chars)."...";
if(isset($img_url) && $img_url != "")  $img_out="<img  class=\"yj_ntimg\" src=\"".$img_url."\" align=\"left\"  border=\"0\" height=\"".$pic_h."\" width=\"".$pic_w."\"  alt=\"\"/>\n";


?>
      
        <li>
           
            <span class="yj_ntt_nt1">
            <a  style="font-size:10px; line-height:12px;" href="<?php echo JRoute::_($link) ?>"><?php echo $row->title ?></a>
            </span>
            
            
          <span class="yj_ntf_nt1"> <?php if(isset($img_url) && $img_url != "")  echo $img_out ?><?php echo $intro?></span><?php if($show_date == 1 || $show_by == 1 || $show_hits == 1 ){ ?><span class="yj_ntf_nt2"><?php if($show_date == 1 ){ ?><strong><?php echo $date  ?></strong><?php } ?><?php if($show_by == 1 ){ ?><br  />By - <?php      

$id = $row->id;
$sql = "SELECT u.name AS author, c.hits, cc.title as category,s.title as section,c.created FROM #__content AS c LEFT JOIN #__categories AS cc ON cc.id=c.catid LEFT JOIN #__sections AS s ON s.id=c.sectionid INNER JOIN #__users AS u ON u.id=c.created_by WHERE c.id=$id";
   
$database->setQuery( $sql );
$result = $database->loadObject();
echo $result->author;
if ($show_hits){
echo " - Hits: ";
echo $result->hits;
}
?><?php } ?>  
</span>  <?php } ?>    
            
            
       </li>
       
       <?php } ?>
       
       
       
        
    </ul>
    </div>
</div>
		
<?php echo '<script defer="defer" src="'.$mosConfig_live_site.'/modules/mod_yj_news_ticker/lib/newsticker.'.$mooext.'" type="text/javascript"></script>';


